<?php echo $this->headScript();?>
<?php echo $this->headLink();?>
<div class="block-search">
<form id="frmsearch" action="/vacancy" method="post">
	<label>Search</label>
	<input name="txtSearch" type="text" value="<?php echo $this->txtSearch; ?>"/>
	<select name="choose">
		<option value="1" <?php echo ($this->choose == 1)? "selected":"" ?> >Company Name</option>
		<option value="2" <?php echo ($this->choose == 2)? "selected":"" ?> >Consultant Name</option>
	</select>
    <input class="button01" name="btSearch" type="submit" value="Search"/>
</form>
</div>  
<br />
	<a href="/default/vacancy/add-vacancy" style="text-decoration:none;">
		<input class="button01" type="button" value="Add Vacancy" />
	</a>
	<input class="button01 delete" type="button" value="Delete" />
<br /><br />

<div id="box">   
    <?php echo $this->partial('vacancy/list-vacancy.phtml', array('paginator' => $this->paginator)); ?>
</div>
<?php if(count($this->paginator)) :?>
<div style="clear:both">&nbsp;</div>
<!-- pagging -->
<div class="footer clearfix">
	<?php echo $this->paginationControl($this->paginator, 'Sliding', 'vacancy/pagination.phtml'); ?>
</div>
<?php endif;?>
<div id="view_vacancy" style="width:700px;height: 350px; overflow-y:scroll; display: none;">&nbsp;</div>
<?php echo $this->partial ( '/vacancy/comment.phtml' )?> 
<div id="allcomment" style="width:500px;height:200px; overflow-y:scroll; display: none;">&nbsp;</div>
<script language="javascript">
$(document).ready(function() {
     //Begin View detail candidate
     $(".view_vacancy").fancybox();
     $(".view_vacancy").click(function(){
         checkLogin();
         $('#view_vacancy').html('');
         var vacancy_id = $(this).attr('id');
         $.ajax({
             url: '/vacancy/view-vacancy',
             type: "POST",
             data: { 
                 vacancy_id: vacancy_id, 
             },
             success: function(result) {
                 $('#view_vacancy').html(result);
             }
         });
     });
     //End View detail candidate
});

$(document).ready(function() {
    //Begin Comment for resume
    $(".addcomment").fancybox();
    $(".addcomment").click(function(){
        $('#contentcomment').val(''); 
        $('input[name=vacancy_id]').val($(this).attr('id'));
    });

    $("#insertcomment").click(function(){
        checkLogin();
        if(!$('#contentcomment').val()) {
            $('#msgcomment').html('Content is not null'); 
            return;
        }
        var vacancy_id = $('input[name=vacancy_id]').val();
        $.ajax({
            url: '/vacancy/save-comment',
            type: "POST",
            data: { 
            	vacancy_id: vacancy_id, 
                consultant_id: $('input[name=consultant_id]').val(), 
                content: $('#contentcomment').val()
            },
            success: function(result) {
                $('#viewcomment' + vacancy_id).html(result);
                $.fancybox.close();
            }
        });
    });
    
    $(".allcomment").fancybox();
    $(".allcomment").click(function(){
        checkLogin();
        var vacancy_id = $(this).attr('id');
        $.ajax({
            url: '/vacancy/all-comment',
            type: "POST",
            data: { 
            	vacancy_id: vacancy_id, 
            },
            success: function(result) {
                $('#allcomment').html(result);
            }
        });
    });
	
	$('.delete').click(function(){
        if($('input[name="vacancy_chk[]"]').is(':checked')) {
            var answer = confirm('Are you sure you want to delete');
            if (answer) {
            	var listVacancy = '';
                var checkboxes = $('input[name="vacancy_chk[]"]:checkbox:checked');
                checkboxes.each(function() {
                	if(listVacancy) listVacancy = listVacancy + ',' + $(this).val();
                	else listVacancy = $(this).val();
                });
            	$.ajax({
              	  	url: '/vacancy/delete-vacancy',
                	type: "POST",
        			data: { 
                       listid: listVacancy
                    },
              	  	success: function(result) {
                  	  	$('#box').html(result);
              	  	}
              	});
            }
        } else {
            alert('Please select vacancy to delete');
            return false;
        }
  	});  
});
</script>
